package com.example.gw_back_end.domain;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import java.util.List;

@Data
public class PageResult<T> {
    private List<T> records; // 分页数据
    private Long current; // 当前页码
    private Long size; // 每页大小
    private Long total; // 总记录数
    private Long pages; // 总页数

    // 封装返回的分页数据
    public static <T> PageResult<T> setPageResult(Page<T> rawPage) {
        PageResult<T> pageResult = new PageResult<>();
        pageResult.setRecords(rawPage.getRecords());
        pageResult.setCurrent(rawPage.getCurrent());
        pageResult.setSize(rawPage.getSize());
        pageResult.setTotal(rawPage.getTotal());
        pageResult.setPages(rawPage.getPages());
        return pageResult;
    }
}
